﻿using UnityEngine;
using System.Collections;

public class DetectorBehaviour : MonoBehaviour {

    private Turret.Turret turretScript;

	// Use this for initialization
	void Start () {
        turretScript = transform.root.GetComponent<Turret.Turret>();
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnTriggerStay(Collider collider)
    {
        if(turretScript.canTarget(collider))
        {
            turretScript.setTarget(collider.gameObject);
        }
    }

    void OnTriggerExit(Collider collider)
    {
        turretScript.targetOutOfRange(collider.gameObject);
    }
}
